<template>
  <a-modal
    class="member-preview-dialog"
    v-model:visible="dataWrapper.visiable"
    title="部门成员列表"
    :width="1200"
  >
    <a-table
      rowKey="id"
      :dataSource="dataWrapper.tableData"
      :columns="dataWrapper.tableColumn"
      :loading="tableLoading"
      size="small"
      :pagination="false"
    ></a-table>
    <div class="member-preview-dialog__page-wrapper">
      <a-pagination
        size="small"
        show-size-changer
        v-model:current="dataWrapper.pageInfo.current"
        v-model:pageSize="dataWrapper.pageInfo.pageSize"
        :total="dataWrapper.pageInfo.total"
        @showSizeChange="sizeChange"
        @change="sizeChange"
      />
    </div>
  </a-modal>
</template>

<script setup lang="ts">
import type { MemberPreviewDialogState } from '../types'

withDefaults(
  defineProps<{
    dataWrapper: MemberPreviewDialogState
    tableLoading?: boolean
  }>(),
  {
    tableLoading: false,
  }
)

const emits = defineEmits<{
  (e: 'enter'): void
  (e: 'pageChange', current: number, pageSize: number): void
}>()

const sizeChange = (current: number, pageSize: number) => {
  emits('pageChange', current, pageSize)
}
</script>

<style lang="scss" scoped>
@include b(member-preview-dialog) {
  @include e(page-wrapper) {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}
</style>
